package com.ziyia.a14;


import android.os.Parcel;
import android.os.Parcelable;

public class Person2 implements Parcelable {
    private String name = "default";
    private Integer age = 20;


    public Person2() {
    }

    public Person2(Parcel in) {
    }

    public Person2(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public static final Creator<Person2> CREATOR = new Creator<Person2>() {
        @Override
        public Person2 createFromParcel(Parcel in) {
            Person2 person2 = new Person2();
            person2.name = in.readString();
            person2.age = in.readInt();
            return person2;
        }

        @Override
        public Person2[] newArray(int size) {
            return new Person2[size];
        }
    };


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeInt(age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public static Creator<Person2> getCREATOR() {
        return CREATOR;
    }

    @Override
    public String toString() {
        return "Person2{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
